package com.sky.service.impl;

import com.alibaba.fastjson2.JSON;
import com.sky.result.Result;
import com.sky.service.ShopService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @program: sky-take-out
 * @description:
 * @author: 酷炫焦少
 * @create: 2024-11-17 19:12
 **/
@Service
@Slf4j
public class ShopServiceImpl implements ShopService {

    @Resource
    private RedisTemplate<Object, Object> redisTemplate;

    @Override
    public Result<Integer> getStatus() {
        String statusStr = (String) redisTemplate.opsForValue().get("shop:status");
        return Result.success((Integer) JSON.parse(statusStr));
    }

    @Override
    public Result<String> setStatus(Integer status) {
        redisTemplate.opsForValue().set("shop:status", JSON.toJSONString(status));
        return Result.success("设置成功");
    }

}
